package com.cts.tmall.app.controller;

import com.cts.tmall.biz.service.AddrService;
import com.cts.tmall.dal.entity.TmallAddr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/addr")
public class AddrController {

    @Autowired
    private AddrService addrService;

    @PostMapping
    public TmallAddr addAddress(@RequestBody TmallAddr addr) {
        return addrService.addAddress(addr);
    }

    @GetMapping
    public List<TmallAddr> queryAddress(TmallAddr addr) {
        return addrService.queryAddress(addr);
    }

    @DeleteMapping
    public void deleteAddress(@RequestBody TmallAddr addr) {
        addrService.deleteAddress(addr.getAddrNo());
    }

    @PutMapping
    public TmallAddr updateAddress(@RequestBody TmallAddr addr) {
        return addrService.updateAddress(addr);
    }
}
